﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace L01
{
    class Program
    {
        static void Main(string[] args)
        {

            int num1, num2, temp;
            Console.WriteLine("请输入第一个数:");
            num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("请输入第二个数:");
            num2 = Convert.ToInt32(Console.ReadLine());
            temp = GCD(num1, num2);
            Console.WriteLine("最大公约数为:{0},最小公倍数为:{1}", temp, num1 * num2 / temp);
            Console.ReadKey();
        }
        /// <summary>
        /// 利用辗转相除法求解最大公约数和最小公倍数
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static int GCD(int m, int n)
        {
            int r, t;
            if (m < n)
            {
                t = n;
                n = m;
                m = t;
            } while (n != 0)
            {
                r = m % n;
                m = n;
                n = r;
            }
            return m;
        }
    }
}
